package com.shun.common;

/**
 * 返回码定义
 *
 * @author lushaonan
 * @since 2021-08-09
 */
public enum RC {

    SUC("0000", "成功！"),

    SYSTEM_UN_TOKEN("1000", "用户的Token为空！"),

    SYSTEM_EXPIRE_TOKEN("1001", "用户的Token过期！"),

    SYSTEM_ERROR_TOKEN("1002", "Token非法！"),

    USER_RELOGIN("1003", "当前设备在线用户数超限，如有需要请重新登录！"),

    SYSTEM_FAIL_AUTH("2000", "权限非法！"),

    SYSTEM_UN_LOGIN("2001", "用户未登录！"),

    SYSTEM_FAIL_LOGIN("2002", "用户名或者密码不正确！"),

    SYSTEM_NON_EXISTENT("2003","账户不存在！"),

    SYSTEM_USER_FREEZE("2004","被冻结的账户无法登陆！"),

    SYSTEM_VALID_PARAM("3000", "参数非法！"),

    SYSTEM_PHONE_ERROR("3001", "手机号非法！"),

    VALIDATE_CODE_ERROR("3002", "验证码号不正确！"),

    VALIDATE_CODE_WAIT_TIME("3003", "手机验证码已经发出，请及时关注手机！"),

    FEIGN_FUSE_ERROR("7000", "业务熔断！"),

    DB_ADD_ERROR("8000", "数据入库失败！"),

    DB_DUP_ERROR("8888", "数据重复入库！"),

    FEIGN_FAIL("9000", "通用业务失败！"),

    UNKNOW("9999", "系统异常！");

    private String code;

    private String msg;

    RC(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getMsg() {
        return this.msg;
    }

    public String getCode() {
        return this.code;
    }

    public R toR() {
        return new R().setMsg(this.getMsg()).setCode(this.code);
    }

    public R toR(String message) {
        return new R().setMsg(message).setCode(this.code);
    }
}
